package com.xnx.bincker.leader.controller.admin;

import com.xnx.bincker.leader.controller.admin.system.IndexController;
import com.xnx.bincker.leader.utils.RestLinkUtils;
import org.springframework.security.access.annotation.Secured;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

import static com.xnx.bincker.leader.utils.RestLinkUtils.links;

/**
 * 管理后台
 */
@RestController
public class AdminController {
    private final RestLinkUtils restLinkUtils;

    public AdminController(RestLinkUtils restLinkUtils) {
        this.restLinkUtils = restLinkUtils;
    }

    /**
     * 获取后台管理接口列表
     */
    @GetMapping("/admin")
    @Secured(value = "ROLE_ADMIN")
    public Map<String, List<RestLinkUtils.Link>> index() throws NoSuchMethodException {
        return links(
                restLinkUtils.getLink("systemApis", IndexController.class.getMethod("index"))
        );
    }
}
